﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.PA
{
    class Class9
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("重大疾病"))
            {
                if (ppa.Age < 1)
                {
                    da.Value = ppa.Amount * 0.25;
                }
                else if (ppa.Age >= 1 && ppa.Age < 2)
                {
                    da.Value = ppa.Amount * 0.5;
                }
                else if (ppa.Age >= 2 && ppa.Age < 3)
                {
                    da.Value = ppa.Amount * 0.75;
                }
                else
                {
                    da.Value = ppa.Amount;
                }
                ppa.IsCurrentFinish = true;
            }
        }

        public void Calc2(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                string s = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"];

                int a = int.Parse(s.Substring(0, 2));
                if (ppa.Age < a)
                {
                    da.Value = ppa.Amount + ppa.TotalFee;
                }
                else
                {

                    int endAge = a + 20;
                    double totalPension = 0;
                    for (int i = a; i < endAge; i++)
                    {
                        int x = (i - a) / 3;
                        totalPension += ppa.Amount * 0.1 + ppa.Amount * (x * 0.006);
                    }

                    da.Value = totalPension - ppa.GetDutyTotalValue("养老保险金");
                }

                ppa.IsCurrentFinish = true;
            }
        }
    }
}
